package com.trkj.usercenter;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.trkj.base.BaseActivity;
import com.trkj.base.User;
import com.trkj.base.utils.UserService;
import com.trkj.taoruiyun.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by LiZanhong on 2015/06/24.
 */
public class UserDetailActivity extends BaseActivity{
    public static final String ACTION = "com.trkj.usercenter.UserDetailActivity";

    @ViewInject(R.id.list)
    private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_detail);
        ViewUtils.inject(this);
        User user = UserService.getInstance(this).parseUser();

        if(user != null){
            List<Map<String, String>> list = new ArrayList<Map<String, String>>();
            putMap("姓名", user.userName, list);
            putMap("部门", getString(R.string.trkj) + "  " + user.deptName, list);
            putMap("性别", user.sex, list);
            putMap("出生日期", user.birthday, list);
            putMap("用户类型", "普通用户", list);
            putMap("入司日期", user.inDate, list);
            putMap("毕业时间", user.endDate, list);
            putMap("就业城市", user.workCity, list);
            putMap("毕业学校", user.university, list);
            putMap("地址", user.address, list);
            putMap("电话", user.telephone, list);
            putMap("QQ", user.qq, list);
            putMap("邮箱", user.email, list);

            SimpleAdapter adapter = new SimpleAdapter(this,
                    list,
                    R.layout.activity_user_detail_item,
                    new String[]{"key", "value"},
                    new int[]{R.id.key, R.id.value});

            listView.setAdapter(adapter);
        }
    }

    private void putMap(String key, String value, List<Map<String, String>> list) {
        Map<String, String> name = new HashMap<String, String>();
        name.put("key", key);
        name.put("value", value);
        list.add(name);
    }

    @Override
    protected String getCustomerTitle() {
        return "用户资料";
    }
}
